using BCrypt.Net;
using Microsoft.Extensions.Configuration;

namespace CustomerManagementSystem.Application;

public class AuthService : IAuthService
{
    private readonly int _workFactor;

    public AuthService(IConfiguration configuration)
    {
        _workFactor = configuration.GetValue("PasswordHash:WorkFactor", 12);
    }

    public string HashPassword(string password)
    {
        return BCrypt.Net.BCrypt.HashPassword(password, _workFactor);
    }

    public bool VerifyPassword(string hashedPassword, string providedPassword)
    {
        return BCrypt.Net.BCrypt.Verify(providedPassword, hashedPassword);
    }
}
